<template>
	<view class="u-page">
		<view class="u-demo-block">
			<view class="u-demo-block__content">
				<u--form labelPosition="left" :model="model1" ref="form1">
					<u-form-item label="充值金额" labelWidth="100" prop="recharge_price" borderBottom ref="item1">
						<u--input type="number" v-model="model1.recharge_price" border="none" placeholder="请输入充值金额"></u--input>
					</u-form-item>
					<u-form-item label="充值类型" labelWidth="100" prop="in_account" @click="showSex = true; hideKeyboard()" borderBottom ref="item1">
						<u--input v-model="model1.name" border="none" placeholder="请选择充值类型"></u--input>
						<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
					<u-form-item label="充值备注" labelWidth="100" prop="in_account" borderBottom ref="item1">
						<u--textarea v-model="model1.remark" border="none" placeholder="请输入充值备注"></u--textarea>
					</u-form-item>
				</u--form>
				<u-button type="success" text="提交" customStyle="margin-top: 50px;height:50px;line-height:50px" @click="submit"></u-button>
				<view class="flex flex-align flex-end">
					<view class="" style="margin-top: 20rpx;" @click="goUrl">充值记录</view>
				</view>
				<u-action-sheet :show="showSex" :actions="fileList1" title="请选择充值类型" description="" @close="showSex = false" @select="sexSelect">
				</u-action-sheet>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				fileList1: [{name:'红包充值',id:1},{name:'流量充值',id:2}],
				disabled1: false,
				tips: '',
				value: '',
				showCalendar: false,
				showBirthday: false,
				model1: {
					name:'',
					recharge_price:'',
					type:'',
					remark:''
				},
				showSex: false,
				
			}
		},
		onReady() {
			// 如果需要兼容微信小程序，并且校验规则中含有方法等，只能通过setRules方法设置规则
		},
		onLoad() {
			
		},
		methods: {
			
			
			goUrl(){
				this.tui.href('/pages/hbchongzhi/hbchongzhiList')
			},
			
			navigateBack() {
				uni.navigateBack()
			},
			sexSelect(e) {
				this.model1.name = e.name
				this.model1.type = e.id
			},
			
			change(e) {
				// console.log(e);
			},
			submit() {
				let that = this
				if(that.model1.remark==''){
					that.tui.toast('备注不能为空')
					return
				}
				that.tui.request("auth.recharge/zfbRecharge", "POST", that.model1, false, false, true).then((res) => {
					that.tui.toast(res.info)
					if(res.code==1){
						setTimeout(() => {
							that.tui.href('/pages/hbchongzhi/hbchongzhiList')
						}, 1000)
					}
				}).catch((res) => {
					
				})
			},
			
			reset() {
				const validateList = ['name', 'recharge_price', 'type', 'remark']
				this.$refs.form1.resetFields()
				this.$refs.form1.clearValidate()
				setTimeout(() => {
					this.$refs.form1.clearValidate(validateList)
					// 或者使用 this.$refs.form1.clearValidate()
				}, 10)
			},
			hideKeyboard() {
				uni.hideKeyboard()
			}
		},
	}
</script>

<style lang="scss">
	.u-demo-block{padding: 20rpx 30rpx;}
	.u-textarea{padding: 0;}
</style>